<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'apiDefinition.label', default: 'ApiDefinition')}"/>
    <title><g:message code="default.create.label" args="[entityName]"/></title>
</head>

<body>
<a href="#create-apiDefinition" class="skip" tabindex="-1"><g:message code="default.link.skip.label"
                                                                      default="Skip to content&hellip;"/></a>

<div class="nav" role="navigation">
    <ul>
        <li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
        <li><g:link class="list" action="index"><g:message code="default.list.label" args="[entityName]"/></g:link></li>
    </ul>
</div>

<div id="create-apiDefinition" class="content scaffold-create" role="main">
    <h1><g:message code="default.create.label" args="[entityName]"/></h1>
    <g:if test="${flash.message}">
        <div class="message" role="status">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${this.apiDefinition}">
        <ul class="errors" role="alert">
            <g:eachError bean="${this.apiDefinition}" var="error">
                <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
                        error="${error}"/></li>
            </g:eachError>
        </ul>
    </g:hasErrors>
    <g:form resource="${this.apiDefinition}" method="POST">
        <fieldset class="form">
            <div class='fieldcontain required'>
                <label for='apiGroup'><g:message code="apiDefinition.apiGroup.label" default="API Group"/><span class='required-indicator'>*</span></label>
                <g:select name="apiGroup" from="${gateway.mgt.api.ApiGroup.all}" optionKey="id" optionValue="name"/>
            </div>

            <div class='fieldcontain required'>
                <label for='name'><g:message code="apiDefinition.name.label" default="Name"/><span class='required-indicator'>*</span></label>
                <g:textField name="name" required="true"/>
            </div>

            <div class='fieldcontain'>
                <label for='description'><g:message code="apiDefinition.description.label" default="Description"/></label>
                <g:textArea name="description"/>
            </div>
            <fieldset class="embedded request"><legend><g:message code="apiDefinition.request.label" default="Request"/></legend>

                <div class='fieldcontain required'>
                    <label for='requestPath'><g:message code="apiDefinition.request.path.label" default="Path"/><span class='required-indicator'>*</span></label>
                    <g:textField name="request.path" required="true" id="requestPath"/>
                </div>
            </fieldset>
            <fieldset class="embedded backend"><legend><g:message code="apiDefinition.backend.label" default="Backend"/></legend>

                <div class='fieldcontain required'>
                    <label for='backendURI'><g:message code="apiDefinition.backend.uri.label" default="URI"/><span class='required-indicator'>*</span></label>
                    <g:textField name="backend.uri" required="true" id="backendURI"/>
                </div>

                <div class='fieldcontain required'>
                    <label for='backendPath'><g:message code="apiDefinition.backend.path.label" default="Path"/><span class='required-indicator'>*</span></label>
                    <g:textField name="backend.path" required="true" id="backendPath"/>
                </div>

                <div class='fieldcontain required'>
                    <label for='backendTimeout'><g:message code="apiDefinition.backend.timeout.label" default="Timeout"/><span class='required-indicator'>*</span></label>
                    <g:textField name="backend.timeout" required="true" id="backendTimeout"/>
                </div>
            </fieldset>
        </fieldset>
        <fieldset class="buttons">
            <g:submitButton name="create" class="save"
                            value="${message(code: 'default.button.create.label', default: 'Create')}"/>
        </fieldset>
    </g:form>
</div>
</body>
</html>
